/**
 * 拨测指标
 **/
  Ext.define('MobileTest.view.window.KeySchemaWindow',{
 	extend:'Ext.window.Window', 	
 	width:800,
 	height:500,
 	modal:true,
 	task:'',
 	title:'添加拨测指标', 	
	initComponent : function() {
		
		var me = this;
		
		var  from =Ext.create('Ext.form.Panel',{
			region:'center',
			bodyPadding: 5,
			layout: 'anchor',
			fieldDefaults: {
            	labelAlign: 'right'            				
        	},
        	defaults: {
        		anchor: '95%',        					
    		},
    		defaultType: 'textfield',
			items:[
					{
        				fieldLabel: '业务编码',
        				name: 'ServiceCode',
        				anchor:'50%',
        				allowBlank: false
    				},{
        				fieldLabel: '指标编码',
        				name: 'TestKeyCode',
        				allowBlank: false,
        				anchor:'50%'
    				},{
        				fieldLabel: '设备编码',
        				name: 'DevId',
        				anchor:'50%'
    				}]			
		});
		
		Ext.applyIf(me, {
			layout:'border',  
			items:[	from],
			 dockedItems:[ {
					xtype : 'toolbar',
					dock : 'top',
					items : [ {
							text : '保存',
							tooltip : '保存添加测试任务',
							iconCls : 'add',
							handler : function() {
								
								var form = me.down('form').getForm();
            					if (form.isValid()) {
                					form.submit({
                						url: 'submitKeySchema',
    									params: {
        									TestTaskCode: me.task.toString()
    									},
                    					success: function(form, action) {
                       						Ext.Msg.alert('Success', action.result.msg);
                       						
                       						me.close();
                    					},
                    					failure: function(form, action) {
                        					Ext.Msg.alert('Failed', action.result.msg);
                    					}
                					});
            					}
							
							}
						}, {
							text : '关闭',
							tooltip : '关闭窗口',
							iconCls : 'add',
							handler : function() {
									me.close();
							}
					}]
				}]
			});
		
		me.callParent(arguments);		
			
		}		
	});